home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianWindows.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  43KB  |  2,214 lines

  1. /*ScianWindows.c
  2.   Eric Pepke
  3.   March 8, 1990
  4.   Window handling routines in Scian
  5. */
  6.  
  7. #include "Scian.h"
  8. #include "ScianTypes.h"
  9. #include "ScianWindows.h"
  10. #include "ScianVisWindows.h"
  11. #include "ScianLists.h"
  12. #include "ScianEvents.h"
  13. #include "ScianColors.h"
  14. #include "ScianErrors.h"
  15. #include "ScianIDs.h"
  16. #include "ScianScripts.h"
  17. #include "ScianTextBoxes.h"
  18. #include "ScianFileSystem.h"
  19. #include "ScianPreferences.h"
  20. #include "ScianDatasets.h"
  21. #include "ScianHelp.h"
  22. #include "ScianDialogs.h"
  23. #include "ScianArrays.h"
  24. #include "ScianFiles.h"
  25. #include "ScianFontSystem.h"
  26. #include "ScianSockets.h"
  27. #include "ScianDraw.h"
  28. #include "ScianObjFunctions.h"
  29. #include "ScianStyle.h"
  30. #include "ScianErrors.h"
  31. #include "ScianRecorders.h"
  32. #include "ScianAnimation.h"
  33. #include "ScianSymbols.h"
  34. #include "ScianDatabase.h"
  35.  
  36. #ifdef RELEASE
  37. #define MINCMAPBITPLANES 9
  38. #else
  39. #define MINCMAPBITPLANES 8
  40. #endif
  41.  
  42. int updateBatch = 0;            /*Current batch of updates*/
  43. WinInfoPtr allWindows = 0;        /*Window info on all windows*/
  44. static short firstTime = 1;        /*First time a new window is made*/
  45. int curDisplayMode;            /*Current display mode*/
  46. Bool rgbp;                /*True iff in rgb mode*/
  47. extern Bool phsco;            /*Phscologram mode*/
  48. WinInfoPtr selWinInfo;            /*Info for currently selected window*/
  49. ObjPtr windowClass = 0;            /*Window class*/
  50. short curCursor = 0;            /*Current cursor*/
  51. ObjPtr clipboard;            /*Clipboard*/
  52. WinInfoPtr inputWindow = 0;        /*Current window for input or 0*/
  53.  
  54. Bool hasRGB;                /*True iff has RGB*/
  55. Bool hasCmap;                /*True iff has color map mode*/
  56. Bool hasRGBDouble;            /*True iff has RGB double buffer mode*/
  57. Bool hasCmapDouble;            /*True iff has RGB double buffer mode*/
  58. Bool hasZbuf;                /*True iff has z buffer mode*/
  59. Bool hasTransparency;            /*True iff has transparency*/
  60. Bool hasTwoSided;            /*True iff has two-sided hardware lighting*/
  61. int nOverDrawPlanes;            /*True iff has overdraw planes*/
  62. Bool pupForOverDraw;            /*True iff popup planes used for over draw*/
  63. Bool rgbGoodForUI;            /*True iff rgb mode is good for UI*/
  64. int scrWidth = 1280, scrHeight = 1024;    /*Width and height of screen, changed by GetConfiguration*/
  65. int cmapBitPlanes = 0;            /*# color map bit planes*/
  66. int rBitPlanes = 0, gBitPlanes = 0, bBitPlanes = 0;
  67.                     /*r, g, b bit planes*/
  68. Bool scavengeColors;            /*True iff scavenge colors*/
  69. Bool showConfig;            /*True iff want to show configuration*/
  70. Bool hasDithering;            /*True iff has dithering*/
  71. Bool hasAntialiasedLines;        /*True iff has anti-aliased lines*/
  72. Bool hasAntialiasedPoints;        /*True iff has anti-aliased points*/
  73. Bool hasDepthCue;            /*True iff system has depth cueing*/
  74. Bool hasStereo;                /*True iff system has stereo*/
  75.  
  76. int drawingQuality = DQ_FULL;       /*The current drawing quality*/
  77.  
  78. #define STAGOVERX    100        /*X over for staggering*/
  79. #define STAGDOWNY    100        /*Y down for staggering*/
  80. #define STAGSTEP    40        /*Step for staggering*/
  81. #define STAGMAX        200        /*Maximum staggering*/
  82.  
  83. int stagger = 0;            /*Current staggering amount*/
  84.  
  85. WinInfoPtr WhichWindow(x, y)
  86. int x, y;
  87. /*Returns which window x, y is in.  Messes up selected window*/
  88. {
  89.     WinInfoPtr retVal = 0;
  90. #ifdef INTERACTIVE
  91. #ifdef WINDOWS4D
  92.     long minDepth;
  93.     Bool first = true;
  94.     WinInfoPtr curWindow;
  95.  
  96.     curWindow = allWindows;
  97.     while (curWindow)
  98.     {
  99.     if (curWindow -> id && (0 == (curWindow -> flags & WINICONIFIED)))
  100.     {
  101.         long depth;
  102.  
  103.         /*It's a valid candidate*/
  104.         depth = windepth(curWindow -> id);
  105.         if (first || (depth < minDepth))
  106.         {
  107.         long ox, oy, sx, sy;
  108.  
  109.         SelWindow(curWindow);
  110.         getorigin(&ox, &oy);
  111.         getsize(&sx, &sy);
  112.  
  113.         if (x >= ox && x <= ox + sx &&
  114.             y >= oy && y <= oy + sy)
  115.         {
  116.             /*Hey, it's in there!*/
  117.             retVal = curWindow;
  118.             minDepth = depth;
  119.             first = false;
  120.         }
  121.         }
  122.     }
  123.     curWindow = curWindow -> next;
  124.     }
  125. #endif
  126. #endif
  127.     return retVal;
  128. }
  129.  
  130. WinInfoPtr TopWindow()
  131. /*Returns the top window.*/
  132. {
  133.     WinInfoPtr retVal = 0;
  134. #ifdef INTERACTIVE
  135. #ifdef WINDOWS4D
  136.     long minDepth;
  137.     Bool first = true;
  138.     WinInfoPtr curWindow;
  139.  
  140.     curWindow = allWindows;
  141.     while (curWindow)
  142.     {
  143.     if (curWindow -> id)
  144.     {
  145.         long depth;
  146.  
  147.         /*It's a valid candidate*/
  148.         depth = windepth(curWindow -> id);
  149.         if (first || (depth < minDepth))
  150.         {
  151.         retVal = curWindow;
  152.         minDepth = depth;
  153.         first = false;
  154.         }
  155.     }
  156.     curWindow = curWindow -> next;
  157.     }
  158. #endif
  159. #endif
  160.     return retVal;
  161. }
  162.  
  163. WinInfoPtr BottomWindow()
  164. /*Returns the bottom window.*/
  165. {
  166.     WinInfoPtr retVal = 0;
  167. #ifdef INTERACTIVE
  168. #ifdef WINDOWS4D
  169.     long maxDepth;
  170.     Bool first = true;
  171.     WinInfoPtr curWindow;
  172.  
  173.     curWindow = allWindows;
  174.     while (curWindow)
  175.     {
  176.     if (curWindow -> id)
  177.     {
  178.         long depth;
  179.  
  180.         /*It's a valid candidate*/
  181.         depth = windepth(curWindow -> id);
  182.         if (first || (depth > maxDepth))
  183.         {
  184.         retVal = curWindow;
  185.         maxDepth = depth;
  186.         first = false;
  187.         }
  188.     }
  189.     curWindow = curWindow -> next;
  190.     }
  191. #endif
  192. #endif
  193.     return retVal;
  194. }
  195.  
  196. #ifdef PROTO
  197. Bool BelowAllBut(WinInfoPtr window1, WinInfoPtr window2)
  198. #else
  199. Bool BelowAllBut(window1, window2)
  200. WinInfoPtr window1, window2;
  201. #endif
  202. /*Returns true iff window1 is below all windows but window2 excluding
  203.   subwindows.*/
  204. {
  205. #ifdef INTERACTIVE
  206. #ifdef WINDOWS4D
  207.     int targetDepth;
  208.     WinInfoPtr curWindow;
  209.  
  210.     /*Get target depth of window1*/
  211.     if (!window1 -> id) return false;
  212.     targetDepth = windepth(window1 -> id);
  213.  
  214.     /*Go through all windows*/
  215.     curWindow = allWindows;
  216.     while (curWindow)
  217.     {
  218.     if (curWindow -> id && !(GetVar((ObjPtr) curWindow, SUPERWINDOW))
  219.         && curWindow != window2)
  220.     {
  221.         long depth;
  222.  
  223.         /*It's a valid candidate*/
  224.         depth = windepth(curWindow -> id);
  225.         if (depth > targetDepth)
  226.         {
  227.         return false;
  228.         }
  229.     }
  230.     curWindow = curWindow -> next;
  231.     }
  232.     return true;
  233.  
  234. #endif
  235. #else
  236.     return false;
  237. #endif
  238. }
  239.  
  240. #ifdef PROTO
  241. Bool AboveAllMainWindows(WinInfoPtr window1)
  242. #else
  243. Bool AboveAllMainWindows(window1)
  244. WinInfoPtr window1;
  245. #endif
  246. /*Returns true iff window1 is above all windows excluding
  247.   subwindows.*/
  248. {
  249. #ifdef INTERACTIVE
  250. #ifdef WINDOWS4D
  251.     int targetDepth;
  252.     WinInfoPtr curWindow;
  253.  
  254.     /*Get target depth of window1*/
  255.     if (!window1 -> id) return false;
  256.     targetDepth = windepth(window1 -> id);
  257.  
  258.     /*Go through all windows*/
  259.     curWindow = allWindows;
  260.     while (curWindow)
  261.     {
  262.     if (curWindow -> id && !(GetVar((ObjPtr) curWindow, SUPERWINDOW)))
  263.     {
  264.         long depth;
  265.  
  266.         /*It's a valid candidate*/
  267.         depth = windepth(curWindow -> id);
  268.         if (depth < targetDepth)
  269.         {
  270.         return false;
  271.         }
  272.     }
  273.     curWindow = curWindow -> next;
  274.     }
  275.     return true;
  276.  
  277. #endif
  278. #else
  279.     return false;
  280. #endif
  281. }
  282.  
  283. #ifndef SelWindow
  284. #ifdef PROTO
  285. void SelWindow(WinInfoPtr w)
  286. #else
  287. void SelWindow(w)
  288. WinInfoPtr w;
  289. #endif
  290. /*Procedure version of SelWindow, useful for debugging*/
  291. {
  292. #if 0
  293.     if (w) 
  294.     printf("SelWindow %s\n", w -> winTitle); 
  295.     else printf("SelWindow null\n");
  296. #endif
  297.     selWinInfo = w; 
  298.     if (w && ((WinInfoPtr) w) -> id) {winset(((WinInfoPtr) w) -> id);\
  299.         curDisplayMode = getdisplaymode();\
  300.         rgbp = (curDisplayMode == DMSINGLE || curDisplayMode == DMDOUBLE) ? false : true;}
  301. }
  302. #endif
  303.  
  304. #ifdef PROTO
  305. void SetWindowPosition(int l, int r, int b, int t)
  306. #else
  307. void SetWindowPosition(l, r, b, t)
  308. int l, r, b, t;
  309. #endif
  310. /*Sets the position of the selected window to l, r, b, t in
  311.   between pixel coordinates*/
  312. {
  313. #ifdef INTERACTIVE
  314. #ifdef WINDOWS4D
  315.     if (selWinInfo -> flags & WINFIXEDSIZE)
  316.     {
  317.     minsize((long) r - l, (long) t - b);
  318.     maxsize((long) r - l, (long) t - b);
  319.     winconstraints();
  320.     }
  321.     winposition((long) l, (long) r - 1, (long) b, (long) t - 1);
  322. #endif
  323. #endif
  324. }
  325.  
  326. #ifdef PROTO
  327. void GetWindowBounds(int *l, int *r, int *b, int *t)
  328. #else
  329. void GetWindowBounds(l, r, b, t)
  330. int *l, *r, *b, *t;
  331. #endif
  332. /*Gets the bounds of the current window into l, r, b, t.
  333.   These are "between the pixels" coordinates*/
  334. {
  335. #ifdef WINDOWS4D
  336.     long w, h;
  337.     getsize(&w, &h);
  338.     *l = 0;
  339.     *r = w;
  340.     *b = 0;
  341.     *t = h;
  342. #else
  343.     *l = 0;
  344.     *r = 10;
  345.     *b = 0;
  346.     *t = 10;
  347. #endif
  348. }
  349.  
  350. void PrintWindowBounds()
  351. {
  352.     int l, r, b, t;
  353.     GetWindowBounds(&l, &r, &b, &t);
  354.     printf("%d %d %d %d\n", l, r, b, t);
  355. }
  356.  
  357. #ifdef PROTO
  358. void GetWindowOrigin(int *x, int *y)
  359. #else
  360. void GetWindowOrigin(x, y)
  361. int *x, *y;
  362. #endif
  363. /*Gets the origin of the current window*/
  364. {
  365. #ifdef WINDOWS4D
  366.     long lx, ly;
  367.     if (fullScreen)
  368.     {
  369.     *x = 0;
  370.     *y = 0;
  371.     }
  372.     else
  373.     {
  374.     getorigin(&lx, &ly);
  375.     *x = lx;
  376.     *y = ly;
  377.     }
  378. #else
  379.     *x = 0;
  380.     *y = 0;
  381. #endif
  382. }
  383.  
  384. static ObjPtr OpenWindowManually(window)
  385. WinInfoPtr window;
  386. /*Asks the user to open the window manually*/
  387. {
  388.     WinInfoPtr alertWindow;
  389.     char message[400];
  390.  
  391.     sprintf(message, "Window '%s' has been turned into an icon.  To continue, first \
  392. dismiss this dialog and then click on the window icon with the left mouse button.", window -> winTitle);
  393.  
  394.     alertWindow = AlertUser(UIERRORALERT, (WinInfoPtr) 0, message,
  395.         0, 0, "OK");
  396.     SetVar((ObjPtr) alertWindow, INHIBITLOGGING, ObjTrue);
  397. }
  398.  
  399. void PushWindow(winInfo)
  400. WinInfoPtr winInfo;
  401. /*Pushes winInfo*/
  402. {
  403. #ifdef GRAPHICS
  404. #ifdef WINDOWS4D
  405.     if (winInfo -> id)
  406.     {
  407.     SelWindow(winInfo);
  408.     winpush();
  409.     Log("pushwindow\n");
  410.     }
  411. #endif
  412. #endif
  413. }
  414.  
  415. #ifdef PROTO
  416. void CEWS(WinInfoPtr window, int sizeX, int sizeY)
  417. #else
  418. void CEWS(window, sizeX, sizeY)
  419. WinInfoPtr window; int sizeX; int sizeY;
  420. #endif
  421. /*Says to a newly created window that the contents expect a certain window
  422.   size*/
  423. {
  424.     Event event;
  425.  
  426.     if (window -> nr != window -> nl + sizeX ||
  427.     window -> nt != window -> nb + sizeY)
  428.     {
  429.     event . type = ET_RESHAPE_WINDOW;
  430.     event . flags = 0;
  431.     event . data . window = window;
  432.     window -> nr = window -> nl + sizeX;
  433.     window -> nt = window -> nb + sizeY;
  434.     PostEvent(&event);
  435.     }
  436. }
  437.  
  438. void PopWindow(winInfo)
  439. WinInfoPtr winInfo;
  440. /*Pops winInfo*/
  441. {
  442.     if (winInfo -> id)
  443.     {
  444. #ifdef GRAPHICS
  445. #ifdef WINDOWS4D
  446.     SelWindow(winInfo);
  447.     winpop();
  448.     if (winInfo -> flags & WINICONIFIED)
  449.     {
  450.         DeferMessage((ObjPtr) winInfo, OPENMANUALLY);
  451.     }
  452. #endif
  453. #endif
  454.     }
  455.     else
  456.     {
  457.     winInfo -> id = NewOpenedWindow(winInfo -> winTitle,
  458.                     winInfo -> minWidth,
  459.                     winInfo -> minHeight,
  460.                     winInfo -> maxWidth,
  461.                     winInfo -> maxHeight,
  462.                     winInfo -> flags);
  463.     CEWS(winInfo, winInfo -> minWidth, winInfo -> minHeight);
  464.     SetMode(winInfo);
  465.     ImInvalid((ObjPtr) winInfo);
  466.     }
  467. }
  468.  
  469. #ifdef PROTO
  470. void CloseWindow(WinInfoPtr window)
  471. #else
  472. void CloseWindow(window)
  473. WinInfoPtr window;
  474. #endif
  475. /*Closes window*/
  476. {
  477.     ObjPtr var;
  478.  
  479.     SelWindow(window);
  480.  
  481.     Log("close\n");
  482.  
  483.     while (var = GetVar((ObjPtr) window, SUPERWINDOW))
  484.     {
  485.     window = (WinInfoPtr) var;
  486.     }
  487.  
  488.     DeferMessage((ObjPtr) window, DISPOSE);
  489.     var = GetVar((ObjPtr) window, SUBWINDOWS);
  490.     if (var)
  491.     {
  492.     ThingListPtr runner;
  493.     runner = LISTOF(var);
  494.     while (runner)
  495.     {
  496.         DeferMessage(runner -> thing, DISPOSE);
  497.         runner = runner -> next;
  498.     }
  499.     }
  500. }
  501.  
  502. void DoShowFrame()
  503. /*Shows the window frame*/
  504. {
  505. #ifndef NOHIDEFRAME
  506.     if (selWinInfo)
  507.     {
  508.     DeferMessage((ObjPtr) selWinInfo, SHOWFRAME);
  509.     }
  510. #endif
  511. }
  512.  
  513. void DoHideFrame()
  514. /*Hides the window frame*/
  515. {
  516. #ifndef NOHIDEFRAME
  517.     if (selWinInfo)
  518.     {
  519.     DeferMessage((ObjPtr) selWinInfo, HIDEFRAME);
  520.     }
  521. #endif
  522. }
  523.  
  524. void DrawWindowInfo(theWindow)
  525. WinInfoPtr theWindow;
  526. /*Draws the window based on WinInfoPtr theWindow into the current set window.
  527.   This is the fundamental window drawing routine.*/
  528. {
  529. #ifdef GRAPHICS
  530.     if (hasDithering)
  531.     {
  532. #ifdef DT_OFF
  533.     dither(DT_OFF);
  534. #endif
  535.     }
  536. #endif
  537.  
  538.  
  539.  
  540.     DrawObject((ObjPtr) theWindow);
  541. }
  542.  
  543. void SaveScreen(window, flags)
  544. WinInfoPtr window;
  545. int flags;
  546. /*Saves a screen*/
  547. {
  548. #ifdef GRAPHICS
  549.     long l, r, b, t;
  550.     int k;
  551.     ObjPtr allRecorders, keyList, var;
  552.  
  553.     keyList = NewList();
  554.     PostfixList(keyList, NewSymbol(CLASSID));
  555.     PostfixList(keyList, NewInt(CLASS_RECORDER));
  556.     PostfixList(keyList, NewSymbol(NAME));
  557.     if (GetPrefInteger(PREF_SAVESCREEN))
  558.     {
  559.     PostfixList(keyList, NewString("PostScript"));
  560.     }
  561.     else
  562.     {
  563.     PostfixList(keyList, NewString("scrsave"));
  564.     }
  565.  
  566.     allRecorders = SearchDatabase(keyList);
  567.     if (allRecorders && LISTOF(allRecorders))
  568.     {
  569.     /*There is a recorder to save*/
  570.     ObjPtr recorder, lastRecorder;
  571.     Bool oldRecordEnabled;
  572.  
  573.     recorder = LISTOF(allRecorders) -> thing;
  574.  
  575.     if (flags & F_OPTIONDOWN)
  576.     {
  577.         /*Save entire screen*/
  578.         SetVar(recorder, FRAMEOX, NewInt(0));
  579.         SetVar(recorder, FRAMEOY, NewInt(0));
  580.         SetVar(recorder, FRAMEWIDTH, NewInt(SCRWIDTH));
  581.         SetVar(recorder, FRAMEHEIGHT, NewInt(SCRHEIGHT));
  582.     }
  583.     else if (flags & F_SHIFTDOWN)
  584.     {
  585.         /*Save with window border*/
  586.         SetVar(recorder, SAVEWINDOWFRAME, ObjTrue);
  587.         AdjustToCurWindow(recorder);
  588.     }
  589.     else
  590.     {
  591.         /*Normal save of window interior*/
  592.         AdjustToCurWindow(recorder);
  593.     }
  594.  
  595.     /*Now do it*/
  596.     lastRecorder = curRecorder;
  597.     oldRecordEnabled = recordEnabled;
  598.     recordEnabled = true;
  599.     curRecorder = recorder;
  600.     if (ConnectRecorder())
  601.     {
  602.         if (PrepareToRecord(1))
  603.         {
  604.         SnapOneFrame();
  605.         StopRecording();
  606.         DisconnectRecorder();
  607.  
  608.         var = GetVar(recorder, FILENAME);
  609.         if (var)
  610.         {
  611.             WinInfoPtr alert;
  612.  
  613.             sprintf(tempStr, "The image was saved in file %s", GetString(var));
  614.  
  615.             alert = AlertUser(UIINFOALERT, (WinInfoPtr) 0, tempStr,
  616.                 (FuncTyp) 0, 0);
  617.             SetVar((ObjPtr) alert, INHIBITLOGGING, ObjTrue);
  618.         }
  619.         }
  620.         else
  621.         {
  622.         WarnUser(CW_SCREENSAVEERROR);
  623.         }
  624.     }
  625.     else
  626.     {
  627.         WarnUser(CW_SCREENSAVEERROR);
  628.     }
  629.     curRecorder = lastRecorder;
  630.     recordEnabled = oldRecordEnabled;
  631.  
  632.     SetVar(recorder, SAVEWINDOWFRAME, ObjFalse);
  633.     }
  634.     else
  635.     {
  636.     WarnUser(CW_NOSCREENSAVER);
  637.     }
  638. #endif
  639. }
  640.  
  641. void PopDatasetsWindow(void)
  642. {
  643.     Log("show datasets\n");
  644.     InhibitLogging(true);
  645.     PopWindow(DatasetsWindow());
  646.     InhibitLogging(false);
  647. }
  648.  
  649. void PopFileReadersWindow(void)
  650. {
  651.     Log("show filereaders\n");
  652.     InhibitLogging(true);
  653.     PopWindow(FileReadersWindow());
  654.     InhibitLogging(false);
  655. }
  656.  
  657. void PopRecorderDriversWindow(void)
  658. {
  659.     Log("show recorders\n");
  660.     InhibitLogging(true);
  661.     PopWindow(RecorderDriversWindow());
  662.     InhibitLogging(false);
  663. }
  664.  
  665. #ifdef PROTO
  666. void ToClipboard(ObjPtr object)
  667. #else
  668. void ToClipboard(object)
  669. ObjPtr object;
  670. #endif
  671. /*Move object to the clipboard*/
  672. {
  673.     ObjPtr *elements;
  674.     elements = ELEMENTS(clipboard);
  675.     elements[0] = object;
  676. }
  677.  
  678. #ifdef PROTO
  679. ObjPtr FromClipboard(void)
  680. #else
  681. ObjPtr FromClipboard()
  682. #endif
  683. /*Return object from the clipboard*/
  684. {
  685.     ObjPtr *elements;
  686.     elements = ELEMENTS(clipboard);
  687.     return elements[0];
  688. }
  689.  
  690. #ifdef PROTO
  691. void CutText(void)
  692. #else
  693. void CutText()
  694. #endif
  695. /*Cuts text*/
  696. {
  697.     if (selWinInfo)
  698.     {
  699.     ObjPtr current;
  700.     current = GetVar((ObjPtr) selWinInfo, CURRENT);
  701.     if (current)
  702.     {
  703.         FuncTyp method;
  704.         method = GetMethod(current, CUT);
  705.         if (method)
  706.         {
  707.         (*method)(current);
  708.         }
  709.     }
  710.     }
  711. }
  712.  
  713. void CopyText(void)
  714. /*Cuts text*/
  715. {
  716.     if (selWinInfo)
  717.     {
  718.     ObjPtr current;
  719.     current = GetVar((ObjPtr) selWinInfo, CURRENT);
  720.     if (current)
  721.     {
  722.         FuncTyp method;
  723.         method = GetMethod(current, COPY);
  724.         if (method)
  725.         {
  726.         (*method)(current);
  727.         }
  728.     }
  729.     }
  730. }
  731.  
  732. #ifdef PROTO
  733. void PasteError(ObjPtr object, ObjPtr value)
  734. #else
  735. void PasteError(object, value)
  736. ObjPtr object;
  737. ObjPtr value;
  738. #endif
  739. /*Makes an error pasting*/
  740. {
  741. #ifdef GRAPHICS
  742.     ringbell();
  743. #endif
  744. }
  745.  
  746. void PasteText(void)
  747. /*Cuts text*/
  748. {
  749.     if (selWinInfo)
  750.     {
  751.     ObjPtr current;
  752.     current = GetVar((ObjPtr) selWinInfo, CURRENT);
  753.     if (current)
  754.     {
  755.         FuncTyp method;
  756.         method = GetMethod(current, PASTE);
  757.         if (method)
  758.         {
  759.         (*method)(current);
  760.         }
  761.     }
  762.     }
  763. }
  764.  
  765. void DoUndoReshape()
  766. /*Undoes a reshape of the window*/
  767. {
  768. #ifdef GRAPHICS
  769. #ifdef WINDOWS4D
  770.     if (selWinInfo)
  771.     {
  772.     SetWindowPosition(selWinInfo -> ol, selWinInfo -> or, selWinInfo -> ob, selWinInfo -> ot);
  773.     }
  774. #endif
  775. #endif
  776. }
  777.  
  778. void DoClose()
  779. /*Closes the current window*/
  780. {
  781.     if (selWinInfo && selWinInfo -> id)
  782.     {
  783.     CloseWindow(selWinInfo);
  784.     }
  785. }
  786.  
  787. void DoSaveScreen()
  788. /*Saves the entire screen*/
  789. {
  790.     SaveScreen(selWinInfo, F_OPTIONDOWN);
  791. }
  792.  
  793. void DoSaveWindow()
  794. /*Saves just a window*/
  795. {
  796.     SaveScreen(selWinInfo, 0);
  797. }
  798.  
  799. static ObjPtr SaveFullScreen(win)
  800. ObjPtr win;
  801. /*Saves the entire screen*/
  802. {
  803.     SaveScreen(selWinInfo, F_OPTIONDOWN);
  804.     return ObjTrue;
  805. }
  806.  
  807. static ObjPtr SaveWindow()
  808. /*Saves just a window*/
  809. {
  810.     SaveScreen(selWinInfo, 0);
  811.     return ObjTrue;
  812. }
  813.  
  814. static ObjPtr SaveFWindow()
  815. /*Saves just a window*/
  816. {
  817.     SaveScreen(selWinInfo, F_SHIFTDOWN);
  818.     return ObjTrue;
  819. }
  820.  
  821. void DropCursorInWindows()
  822. /*Drops the cursor in all the windows*/
  823. {
  824. #ifdef GRAPHICS
  825. #ifdef CURSORS4D
  826.     WinInfoPtr curWindow;
  827.  
  828.     curWindow = allWindows;
  829.     while (curWindow)
  830.     {
  831.         if (curWindow -> id)
  832.         {
  833.         SetDrawingWindow(curWindow);
  834.  
  835.         if (curCursor < 0)
  836.         {
  837.             cursoff();
  838.         }
  839.         else
  840.         {
  841.             curson();
  842.             setcursor(curCursor, (Colorindex) 1, (Colorindex) 0);
  843.         }
  844.         RestoreDrawingWindow();
  845.         }
  846.         curWindow = curWindow -> next;
  847.     }
  848. #endif
  849. #endif
  850. }
  851.  
  852. void MySetCursor(cursorNumber)
  853. int cursorNumber;
  854. /*Sets the cursor to cursorNumber*/
  855. {
  856. #ifdef GRAPHICS
  857.     if (cursorNumber != curCursor)
  858.     {
  859.     curCursor = cursorNumber;
  860.  
  861.     DropCursorInWindows();
  862.     }
  863. #endif
  864. }
  865.  
  866. #ifdef PROTO
  867. WindowID NewOpenedWindow(char *title, int minWidth, int minHeight, int maxWidth, int maxHeight, long flags)
  868. #else
  869. WindowID NewOpenedWindow(title, minWidth, minHeight, maxWidth, maxHeight, flags)
  870. char *title;
  871. int minWidth, minHeight, maxWidth, maxHeight;
  872. long flags;
  873. #endif
  874. /*Creates a new opened window with title, and size determined by minWidth,
  875.   minHeight, maxWidth, and maxHeight and returns a window ID which will
  876.   differ from machine to machine.*/
  877. {
  878.     WindowID retVal = 0;
  879.     long ox, oy;
  880.     Bool gottaSetMinMax = false;
  881.  
  882.     /*Set up initial parameters for window*/
  883. #ifdef WINDOWS4D
  884.  
  885.  
  886.     /*No border if it can be done and the window wants it*/
  887. #ifndef NOHIDEFRAME
  888.     if (flags & WINNOFRAME)
  889.     {
  890.     noborder();
  891.     }
  892. #endif
  893.  
  894.     /*Set its position, etc.*/
  895.     if (flags & WINCENTERED)
  896.     {
  897.     /*Center using minimum size around center of screen*/
  898.     ox = scrWidth / 2 - minWidth / 2;
  899.     oy = scrHeight / 2 - minHeight / 2;
  900.     prefposition(ox, ox + minWidth - 1, oy, oy + minHeight - 1);
  901.     }
  902.     else if (flags & WINFIXEDLOC)
  903.     {
  904.     /*Fixed location.  Use max as origin*/
  905.     prefposition(maxWidth, minWidth + maxWidth - 1,
  906.              maxHeight, minHeight + maxHeight - 1);
  907.     }
  908.     else
  909.     {
  910.     /*Free window*/
  911.     if (runningScript || runningRemote || GetPrefTruth(PREF_NEWWINPLACE))
  912.     {
  913.         /*Place in fixed position*/
  914.         ox = STAGOVERX + stagger;
  915.         oy = scrHeight - STAGDOWNY - stagger;
  916.         prefposition(ox, ox + minWidth - 1, oy - minHeight + 1, oy);
  917.         stagger += STAGSTEP;
  918.         if (stagger > STAGMAX) stagger = 0;
  919.         gottaSetMinMax = true;
  920.      }
  921.     else
  922.     {
  923. #ifdef INTERACTIVE
  924.         /*Wait for mouse to come up*/
  925.         while (getbutton(MOUSE1) || getbutton(MOUSE2) || getbutton(MOUSE3));
  926. #endif
  927.         minsize(minWidth, minHeight);
  928.         maxsize(maxWidth, maxHeight);
  929.     }
  930.     }
  931.  
  932.     /*Create the window*/
  933.     retVal = winopen(title);
  934.     wintitle(title);
  935.  
  936.     /*Set up the default characteristics*/
  937.     winset(retVal);
  938.  
  939.     if (gottaSetMinMax)
  940.     {
  941.     minsize(minWidth, minHeight);
  942.     maxsize(maxWidth, maxHeight);
  943.     winconstraints();
  944.     }
  945.  
  946. #ifdef GL4D
  947. #ifdef GLC_OLDPOLYGON
  948.     glcompat(GLC_OLDPOLYGON, FALSE);
  949. #endif
  950. #ifdef GLC_ZRANGEMAP
  951.     glcompat(GLC_ZRANGEMAP, TRUE);
  952. #endif
  953. #endif
  954.     if (AreFlagsDoubleBuf(flags))
  955.     {
  956.     doublebuffer();
  957.     }
  958.     else
  959.     {
  960.     singlebuffer();
  961.     }
  962.     if (nOverDrawPlanes && pupForOverDraw == false)
  963.     {
  964.     overlay(2);
  965.     }
  966.     gconfig();
  967.  
  968. #endif
  969.  
  970.     /*Now that we've made the first window, it's safe to initialize the rest*/
  971.     InitStuff();
  972.  
  973.     return retVal;
  974. }
  975.  
  976. void SetMinSize(winInfo, mw, mh)
  977. WinInfoPtr winInfo;
  978. int mw, mh;
  979. /*Sets the minimum size of window winInfo to mw, mh*/
  980. {
  981. #ifdef WINDOWS4D
  982.     SelWindow(winInfo);
  983.     minsize(mw, mh);
  984.     winconstraints();
  985. #endif
  986. }
  987.  
  988. void SetMode(curWinInfo)
  989. WinInfoPtr curWinInfo;
  990. /*Sets the mode of the current window according to the flags*/
  991. {
  992.     SelWindow(curWinInfo);
  993. #ifdef WINDOWS4D
  994.     if (curWinInfo -> flags & WINRGB)
  995.     {
  996.         if (hasRGB)
  997.         {
  998.         RGBmode();
  999.         }
  1000.         else
  1001.         {
  1002.         cmode();
  1003.         }
  1004.     }
  1005.     else
  1006.     {
  1007.         if (hasCmap)
  1008.         {
  1009.         cmode();
  1010.         }
  1011.         else
  1012.         {
  1013.         RGBmode();
  1014.         }
  1015.     }
  1016.     if (IsDoubleBuf(curWinInfo))
  1017.     {
  1018.         doublebuffer();
  1019.     }
  1020.     else
  1021.     {
  1022.         singlebuffer();
  1023.     }
  1024.     gconfig();
  1025. #endif
  1026. }
  1027.  
  1028. void DoMaxScreen()
  1029. /*Makes the current window go to the max screen*/
  1030. {
  1031. #ifdef GRAPHICS
  1032. #ifdef WINDOWS4D
  1033.     SetWindowPosition(0, SCRWIDTH, 0, SCRHEIGHT);
  1034. #endif
  1035. #endif
  1036.     phsco = false;
  1037. }
  1038.  
  1039.  
  1040. void DoVideoScreen()
  1041. /*Makes the current window go to the video screen*/
  1042. {
  1043.     int x, y;
  1044. #ifdef GRAPHICS
  1045. #ifdef WINDOWS4D
  1046.     GetScreenSize(&x, &y);
  1047.     SetWindowPosition(0, x, 0, y);
  1048. #endif
  1049. #endif
  1050.     phsco = false;
  1051. }
  1052.  
  1053. void Do2VideoScreen()
  1054. /*Makes the current window go to twice the video screen*/
  1055. {
  1056.     int x, y;
  1057. #ifdef GRAPHICS
  1058. #ifdef WINDOWS4D
  1059.     GetScreenSize(&x, &y);
  1060.     SetWindowPosition(0, 2 * x, 0, 2 * y);
  1061. #endif
  1062. #endif
  1063.     phsco = false;
  1064. }
  1065.  
  1066. void LocateWindow(l, r, b, t)
  1067. int l, r, b, t;
  1068. /*Locates current window at l, r, b, t*/
  1069. {
  1070. #ifdef GRAPHICS
  1071. #ifdef WINDOWS4D
  1072.     SetWindowPosition(l, r, b, t);
  1073. #endif
  1074. #endif
  1075.     phsco = false;
  1076. }
  1077.  
  1078. void DoPhscoScreen()
  1079. /*Makes the current window go to the phscologram screen*/
  1080. {
  1081. #ifdef GRAPHICS
  1082. #ifdef WINDOWS4D
  1083.     SetWindowPosition(0, 1100, 0, 615);
  1084. #endif
  1085. #endif
  1086.     phsco = true;
  1087. }
  1088.  
  1089. static void NullAndVoid()
  1090. /*Default do-nothing void routine*/
  1091. {
  1092. }
  1093.  
  1094. ObjPtr WinFullScreen(ObjPtr win)
  1095. /*Sets win (which is also current) to the full screen*/
  1096. {
  1097.     SetWindowPosition(0, SCRWIDTH, 0, SCRHEIGHT);
  1098.     phsco = false;
  1099.     return ObjTrue;
  1100. }
  1101.  
  1102. ObjPtr WinVideoScreen(ObjPtr win)
  1103. /*Sets win (which is also current) to the video screen*/
  1104. {
  1105.     int x, y;
  1106.  
  1107.     GetScreenSize(&x, &y);
  1108.     SetWindowPosition(0, x, 0, y);
  1109.  
  1110.     phsco = false;
  1111.     return ObjTrue;
  1112. }
  1113.  
  1114. ObjPtr WinDoubleVidScreen(ObjPtr win)
  1115. /*Sets win (which is also current) to double the video screen*/
  1116. {
  1117.     int x, y;
  1118.  
  1119.     GetScreenSize(&x, &y);
  1120.     SetWindowPosition(0, 2 * x, 0, 2 * y);
  1121.  
  1122.     phsco = false;
  1123.     return ObjTrue;
  1124. }
  1125.  
  1126. ObjPtr WinPrevScreen(ObjPtr win)
  1127. /*Undoes a reshape of the window*/
  1128. {
  1129.     if (selWinInfo)
  1130.     {
  1131.     SetWindowPosition(selWinInfo -> ol, selWinInfo -> or, selWinInfo -> ob, selWinInfo -> ot);
  1132.     }
  1133. }
  1134.  
  1135. WinInfoPtr NewWinInfo(superClass, windowID, flags, title, 
  1136.         minWidth, minHeight, maxWidth, maxHeight)
  1137. ObjPtr superClass;
  1138. long windowID;
  1139. long flags;
  1140. char *title;
  1141. int minWidth, minHeight, maxWidth, maxHeight;
  1142. /*Creates a new window information record associated with windowID 
  1143.   and returns it, or NIL if it couldn't 
  1144.   allocate one.  Sets everything to the default.  Sets the superclass to
  1145.   superClass so that it can inherit*/
  1146. {
  1147.     WinInfoPtr newInfo;
  1148.  
  1149. #ifdef GRAPHICS
  1150.     if (windowID)
  1151.     {
  1152.     winset(windowID);
  1153.     }
  1154. #endif
  1155.  
  1156.     if (firstTime)
  1157.     {
  1158. #ifdef GRAPHICS
  1159.     /*Finish the initialization that we couldn't do until the 1st window*/
  1160.     firstTime = 0;
  1161. #endif
  1162.     }
  1163.  
  1164.     if (superClass == 0)
  1165.     {
  1166.     superClass = windowClass;
  1167.     }
  1168.  
  1169.     newInfo = (WinInfoPtr) NewObject(superClass, sizeof(WinInfo) - sizeof(Thing));
  1170.     if (newInfo)
  1171.     {
  1172.     int k;
  1173.     WinInfoPtr *runner;
  1174.     long ox, oy, sx, sy;
  1175.  
  1176.     /*Set up the new info to point to this window*/
  1177.     newInfo -> id = windowID;
  1178.  
  1179.     /*Link the new info into the list*/
  1180.     runner = &(allWindows);
  1181.     while (*runner)
  1182.     {
  1183.         runner = &((*runner) -> next);
  1184.     }
  1185.     *runner = newInfo;
  1186.     newInfo -> next = 0;
  1187.  
  1188.     /*Initialize values to defaults*/
  1189.         SETOBJTYPE(newInfo -> thing . flags, WINDOW);
  1190.     AddToReferenceList((ObjPtr) newInfo);
  1191.         
  1192.     newInfo -> flags = flags;
  1193.     ImInvalid((ObjPtr) newInfo);
  1194.  
  1195.     newInfo -> minWidth = minWidth;
  1196.     newInfo -> maxWidth = maxWidth;
  1197.     newInfo -> minHeight = minHeight;
  1198.     newInfo -> maxHeight = maxHeight;
  1199.  
  1200.     if (windowID)
  1201.     {
  1202.         /*Set to the current window and set the graphics state*/
  1203.         SetMode(newInfo);
  1204.     }
  1205.     
  1206.     /*Save the title*/
  1207.     strcpy(newInfo -> winTitle, title);
  1208.     SetVar((ObjPtr) newInfo, NAME, NewString(title));
  1209.  
  1210.     /*Select the new window*/
  1211.     SelWindow(newInfo);
  1212.  
  1213.     /*Stuff ol, or, ob, ot*/
  1214. #ifdef WINDOWS4D
  1215. #ifdef GRAPHICS
  1216.     if (windowID)
  1217.     {
  1218.         getorigin(&ox, &oy);
  1219.         getsize(&sx, &sy);
  1220.     }
  1221.     else
  1222.     {
  1223.         ox = SCRWIDTH / 2 - minWidth / 2;
  1224.         oy = SCRHEIGHT / 2 - minHeight / 2;
  1225.         sx = minWidth;
  1226.         sy = minHeight;
  1227.     }
  1228.     newInfo -> nl = ox;
  1229.     newInfo -> nr = ox + sx;
  1230.     newInfo -> nb = oy;
  1231.     newInfo -> nt = oy + sy;
  1232.     newInfo -> ol = ox;
  1233.     newInfo -> or = ox + sx;
  1234.     newInfo -> ob = oy;
  1235.     newInfo -> ot = oy + sy;
  1236. #endif
  1237. #endif
  1238.  
  1239.     /*Set some methods*/
  1240.  
  1241.     if (!((flags & WINFIXEDLOC) || (flags & WINFIXEDSIZE)))
  1242.     {
  1243.         SetMethod((ObjPtr) newInfo, FULLSCREEN, WinFullScreen);
  1244.         SetMethod((ObjPtr) newInfo, VIDEOSCREEN, WinVideoScreen);
  1245.         SetMethod((ObjPtr) newInfo, DOUBLEVIDSCREEN, WinDoubleVidScreen);
  1246.         SetMethod((ObjPtr) newInfo, PREVSCREEN, WinPrevScreen);
  1247.     }
  1248.     SetMethod((ObjPtr) newInfo, SAVEWINDOW, SaveWindow);
  1249.     SetMethod((ObjPtr) newInfo, SAVEFWINDOW, SaveFWindow);
  1250.     SetMethod((ObjPtr) newInfo, SAVESCREEN, SaveFullScreen);
  1251.  
  1252.     /*Return the new info*/
  1253.     return newInfo;
  1254.     }
  1255.     else
  1256.     {
  1257.     /*Failed to allocate info.  Return NIL*/
  1258.     OMErr();
  1259.     return (WinInfoPtr) 0;
  1260.     }
  1261. }
  1262.  
  1263. #ifdef PROTO
  1264. void SetWindowTitle(ObjPtr win, char *title)
  1265. #else
  1266. void SetWindowTitle(win, title)
  1267. ObjPtr win;
  1268. char *title;
  1269. #endif
  1270. /*Sets window title to title*/
  1271. {
  1272.     strcpy(((WinInfoPtr) win) -> winTitle, title);
  1273.     SetVar((ObjPtr) win, NAME, NewString(title));
  1274. #ifdef GRAPHICS
  1275. #ifdef WINDOWS4D
  1276.     if (!(win -> flags & WINNOFRAME))
  1277.     {
  1278.     wintitle(title);
  1279.     }
  1280. #endif
  1281. #endif
  1282. }
  1283.  
  1284. Bool IsValidWindow(window)
  1285. WinInfoPtr window;
  1286. /*Returns true iff window is a valid window*/
  1287. {
  1288.     register WinInfoPtr runner;
  1289.  
  1290.     runner = allWindows;
  1291.     while (runner)
  1292.     {
  1293.     if (runner == window)
  1294.     {
  1295.         return true;
  1296.     }
  1297.     runner = runner -> next;
  1298.     }
  1299.     return false;
  1300. }
  1301.  
  1302. WinInfoPtr GetWinInfo(winID)
  1303. long winID;
  1304. /*Gets the winInfo record associated with winID or returns NIL*/
  1305. {
  1306.     register WinInfoPtr runner;
  1307.     if (winID == 0) return 0;
  1308.  
  1309.     runner = allWindows;
  1310.     while (runner)
  1311.     {
  1312.     if (runner -> id == winID)
  1313.     {
  1314.         return runner;
  1315.     }
  1316.     runner = runner -> next;
  1317.     }
  1318.     return (WinInfoPtr) 0;
  1319. }
  1320.  
  1321. int strcmp2(s1, s2)
  1322. char s1[], s2[];
  1323. /*Compares s1 and s2 without regard to case*/
  1324. {
  1325.     int k;
  1326.  
  1327.     for (k = 0; s1[k]; ++k)
  1328.     {
  1329.     if (toupper(s1[k]) < toupper(s2[k])) return -k - 1;
  1330.     if (toupper(s1[k]) > toupper(s2[k])) return k + 1;
  1331.     }
  1332.     return s2[k] ? -k - 1 : 0;
  1333. }
  1334.  
  1335. int strcmp3(s1, s2)
  1336. char s1[], s2[];
  1337. /*Compares s1 and s2 without regard to case, AND s2 can be longer*/
  1338. {
  1339.     int k;
  1340.  
  1341.     for (k = 0; s1[k]; ++k)
  1342.     {
  1343.     if (toupper(s1[k]) < toupper(s2[k])) return -k - 1;
  1344.     if (toupper(s1[k]) > toupper(s2[k])) return k + 1;
  1345.     }
  1346.     return 0;
  1347. }
  1348.  
  1349. #ifdef PROTO
  1350. Bool ObjectNameMatches(char *pattern, char *candidate)
  1351. #else
  1352. Bool ObjectNameMatches(pattern, candidate)
  1353. char *pattern;
  1354. char *candidate;
  1355. #endif
  1356. /*Returns true if object name candidate matches pattern up until pattern
  1357.   stops.  There may be more stuff after the end of pattern.  For example, 
  1358.   pattern "foo" matches candidate "foobar"*/
  1359. {
  1360.     return strcmp3(pattern, candidate) ? false : true;
  1361. }
  1362.  
  1363. WinInfoPtr GetWinFromTitle(title)
  1364. char *title;
  1365. /*Gets the winInfo record associated with title.  If there is none or there
  1366.   is more than one, returns nil*/
  1367. {
  1368.     register WinInfoPtr runner;
  1369.     runner = allWindows;
  1370.     while (runner)
  1371.     {
  1372.     if (!strcmp2(runner -> winTitle, title))
  1373.     {
  1374.         if (!GetVar((ObjPtr) runner, SUPERWINDOW))
  1375.         {
  1376.         /*Only return if not a subwindow*/
  1377.         return runner;
  1378.         }
  1379.     }
  1380.     runner = runner -> next;
  1381.     }
  1382.     return (WinInfoPtr) 0;
  1383. }
  1384.  
  1385. ObjPtr DisposeWindow(window)
  1386. WinInfoPtr window;
  1387. /*Disposes of the given window and closes the window.*/
  1388. {
  1389.     WinInfoPtr *runner;
  1390.     runner = &allWindows;
  1391.     while (*runner)
  1392.     {
  1393.     if ((*runner) == window)
  1394.     {
  1395.         WinInfoPtr next;
  1396.         FuncTyp closeRoutine;
  1397.         
  1398.         /*Found it.  Close it.*/
  1399.         SelWindow(window);
  1400.         MakeMeCurrent(NULLOBJ);
  1401.  
  1402.         /*First check for hide routine*/
  1403.         closeRoutine = GetMethod((ObjPtr) *runner, HIDE);
  1404.         if (closeRoutine && IsTrue((*closeRoutine)(*runner)))
  1405.         {
  1406. #ifdef WINDOWS4D
  1407.         winclose((*runner) -> id);
  1408. #endif
  1409.         if ((*runner) == inputWindow)
  1410.         {
  1411.             inputWindow = 0;
  1412.         }
  1413.         (*runner) -> id = 0;
  1414.         SelWindow((WinInfoPtr) 0);
  1415.  
  1416.         /*Just advance*/
  1417.         runner = &((*runner) -> next);
  1418.         }
  1419.         else
  1420.         {
  1421.         closeRoutine = GetMethod((ObjPtr) *runner, CLOSE);
  1422.         if (closeRoutine && !IsTrue((*closeRoutine)(*runner)))
  1423.         {
  1424.             return ObjFalse;
  1425.         }
  1426.         SelWindow(*runner);
  1427.  
  1428. #ifdef WINDOWS4D
  1429.         winclose((*runner) -> id);
  1430. #endif
  1431.         if ((*runner) == inputWindow)
  1432.         {
  1433.             inputWindow = 0;
  1434.         }
  1435.         SelWindow(0);
  1436.         next = (*runner) -> next;
  1437.         (*runner) -> id = 0;
  1438.         DeleteThing((ObjPtr) *runner);
  1439.         *runner = next;
  1440.         }
  1441.     }
  1442.     else
  1443.     {
  1444.         /*Not found.  Just advance.*/
  1445.         runner = &((*runner) -> next);
  1446.     }
  1447.     }
  1448.     if (!allWindows)
  1449.     {
  1450.     DoQuit();
  1451.     }
  1452.     return ObjTrue;
  1453. }
  1454.  
  1455. Bool DisposeAllWindows()
  1456. /*Disposes of all the windows.  Returns true iff successful.*/
  1457. {
  1458.     while (allWindows)
  1459.     {
  1460.     WinInfoPtr next;
  1461.     FuncTyp closeRoutine;
  1462.  
  1463.     closeRoutine = GetMethod((ObjPtr) allWindows, CLOSE);
  1464.     if (closeRoutine && !IsTrue((*closeRoutine)(allWindows)))
  1465.     {
  1466.         return false;
  1467.     }
  1468.     if (allWindows -> id)
  1469.     {
  1470. #ifdef WINDOWS4D
  1471.         winclose(allWindows -> id);
  1472. #endif
  1473.         allWindows -> id = 0;
  1474.     }
  1475.  
  1476.     next = allWindows -> next;
  1477.     DeleteThing((ObjPtr) allWindows);
  1478.     allWindows = next;
  1479.     }
  1480.     inputWindow = 0;
  1481.     return true;
  1482. }
  1483.  
  1484. int ReshapeWindow(window)
  1485. ObjPtr window;
  1486. /*Reshapes a window to a new viewport.*/
  1487. {
  1488.     if (selWinInfo)
  1489.     {
  1490.     FuncTyp reshapeMethod;
  1491.     reshapeMethod = GetMethod(window, RESHAPE);
  1492.     if (reshapeMethod)
  1493.     {
  1494.         (*reshapeMethod)(window, 
  1495.         ((WinInfoPtr) selWinInfo) -> ol,
  1496.         ((WinInfoPtr) selWinInfo) -> or,
  1497.         ((WinInfoPtr) selWinInfo) -> ob,
  1498.         ((WinInfoPtr) selWinInfo) -> ot,
  1499.         ((WinInfoPtr) selWinInfo) -> nl,
  1500.         ((WinInfoPtr) selWinInfo) -> nr,
  1501.         ((WinInfoPtr) selWinInfo) -> nb,
  1502.         ((WinInfoPtr) selWinInfo) -> nt
  1503.         );
  1504.     }
  1505.     }
  1506.     return true;
  1507. }
  1508.  
  1509. void ForAllWindows(routine)
  1510. void (*routine)();
  1511. /*Performs (*routine)(window) on all windows*/
  1512. {
  1513.     WinInfoPtr curWindow;
  1514.     curWindow = allWindows;
  1515.     while (curWindow)
  1516.     {
  1517.     (*routine)(curWindow);
  1518.     curWindow = curWindow -> next;
  1519.     }
  1520. }
  1521.  
  1522. #ifdef PROTO
  1523. Bool IdleOneWindow(WinInfoPtr curWindow)
  1524. #else
  1525. Bool IdleOneWindow(curWindow)
  1526. WinInfoPtr curWindow;
  1527. #endif
  1528. /*Idles one window.  Side effect--may select a window*/
  1529. {
  1530.     FuncTyp method;
  1531.     Bool retVal;
  1532.  
  1533.     retVal = false;
  1534.  
  1535.     if (curWindow -> id == 0) return;
  1536.  
  1537. #ifdef GRAPHICS
  1538.     SetDrawingWindow(curWindow);
  1539.     MakeVar(curWindow, NAME);
  1540.  
  1541.     method = GetMethod((ObjPtr) curWindow, MAKEDRAWN);
  1542.     if (method)
  1543.     {
  1544.         if (IsTrue((*method)(curWindow)))
  1545.         {
  1546.         /*Window was drawn*/
  1547.  
  1548.         retVal = true;
  1549.         }
  1550.     }
  1551.  
  1552.     RestoreDrawingWindow();
  1553.    return retVal;
  1554. #endif
  1555.     
  1556. }
  1557.  
  1558. Bool IdleAllWindows()
  1559. /*Idles all the windows, redrawing double-buffered ones.  Returns true
  1560.   iff any redrawing was done*/
  1561. {
  1562.     Bool retVal = false;
  1563. #ifdef GRAPHICS
  1564.     WinInfoPtr curWindow;
  1565.     WinInfoPtr oldWindow;
  1566.     int dummy;
  1567.  
  1568.     oldWindow = selWinInfo;
  1569.     ++updateBatch;
  1570.  
  1571.     if (inputWindow && IsValidWindow(inputWindow))
  1572.     {
  1573.     if (IdleOneWindow(inputWindow))
  1574.     {
  1575.         retVal = true;
  1576.     }
  1577.     }
  1578.  
  1579.     if (!AltDown())
  1580.     {
  1581.     for (curWindow = allWindows; curWindow; curWindow = curWindow -> next)
  1582.     {
  1583.         if (curWindow -> id == 0) continue;
  1584.  
  1585.         if (curWindow == inputWindow) continue;
  1586.  
  1587.         if (IdleOneWindow(curWindow))
  1588.         {
  1589.         retVal = true;
  1590.         }
  1591.     }
  1592.     }
  1593.  
  1594.     if (oldWindow && (oldWindow != selWinInfo))
  1595.     {
  1596.     SelWindow(oldWindow);
  1597.     }
  1598. #endif
  1599.     return retVal;
  1600. }
  1601.  
  1602.  
  1603. void DeferClose()
  1604. /*Does a close as a deferred task*/
  1605. {
  1606.     if (selWinInfo)
  1607.     {
  1608.     CloseWindow(selWinInfo);
  1609.     }
  1610. }
  1611.  
  1612. void GetConfiguration()
  1613. /*Gets the configuration of the system*/
  1614. {
  1615.     Bool tryRGB = true, tryCmap = true;
  1616.     Bool tryDouble = true;
  1617.  
  1618.     if (getenv("SCIAN_SHOW_CONFIG"))
  1619.     {
  1620.     showConfig = true;
  1621.     }
  1622.     else
  1623.     {
  1624.     showConfig = false;
  1625.     }
  1626.  
  1627.     if (showConfig)
  1628.     {
  1629.     printf("Calculating machine parameters\n");
  1630.     }
  1631.  
  1632.     if (getenv("SCIAN_VETO_DOUBLE"))
  1633.     {
  1634.     if (showConfig)
  1635.     {
  1636.         printf("Double buffer mode vetoed.\n");
  1637.     }
  1638.     tryDouble = false;
  1639.     }
  1640.     else
  1641.     {
  1642.     tryDouble = true;
  1643.     }
  1644.  
  1645.     if (getenv("SCIAN_VETO_RGB"))
  1646.     {
  1647.     if (showConfig)
  1648.     {
  1649.         printf("RGB mode vetoed.\n");
  1650.     }
  1651.     tryRGB = false;
  1652.     }
  1653.     else
  1654.     {
  1655.     tryRGB = true;
  1656.     }
  1657.  
  1658.     if (getenv("SCIAN_VETO_CMAP"))
  1659.     {
  1660.     if (showConfig)
  1661.     {
  1662.         printf("Color map mode vetoed.\n");
  1663.     }
  1664.     tryCmap = false;
  1665.     }
  1666.     else
  1667.     {
  1668.     tryCmap = true;
  1669.     }
  1670.  
  1671. #ifdef GRAPHICS
  1672.     /*Find out the size of the screen*/
  1673. #ifdef GD_XPMAX
  1674.     scrWidth = getgdesc(GD_XPMAX);
  1675. #else
  1676.     scrWidth = CSCRWIDTH;
  1677. #endif
  1678. #ifdef GD_YPMAX
  1679.     scrHeight = getgdesc(GD_YPMAX);
  1680. #else
  1681.     scrHeight = CSCRHEIGHT;
  1682. #endif
  1683.  
  1684.     if (showConfig)
  1685.     {
  1686.     printf("Screen size: %d by %d\n", scrWidth, scrHeight);
  1687.     }
  1688.  
  1689.     /*See about the colors*/
  1690.     if (tryRGB)
  1691.     {
  1692.     /*Test RGB*/
  1693.     hasRGB = true;
  1694.     rgbGoodForUI = false;
  1695.  
  1696.     if (tryDouble)
  1697.     {
  1698.     /*Try double buffer RGB*/
  1699.     hasRGBDouble = true;
  1700.  
  1701.     /*See all bit planes for IBM version*/
  1702. #ifdef GD_BITS_NORM_DBL_RGB
  1703.     rBitPlanes = getgdesc(GD_BITS_NORM_DBL_RGB);
  1704.     gBitPlanes = getgdesc(GD_BITS_NORM_DBL_RGB);
  1705.     bBitPlanes = getgdesc(GD_BITS_NORM_DBL_RGB);
  1706. #endif
  1707.  
  1708.     /*Now individual bit planes for IRIS version*/
  1709. #ifdef GD_BITS_NORM_DBL_RED
  1710.     rBitPlanes = getgdesc(GD_BITS_NORM_DBL_RED);
  1711. #endif
  1712. #ifdef GD_BITS_NORM_DBL_GREEN
  1713.     gBitPlanes = getgdesc(GD_BITS_NORM_DBL_GREEN);
  1714. #endif
  1715. #ifdef GD_BITS_NORM_DBL_BLUE
  1716.     bBitPlanes = getgdesc(GD_BITS_NORM_DBL_BLUE);
  1717. #endif
  1718.  
  1719.     /*If not enough bit planes, shoot for single buffer*/
  1720.     if (rBitPlanes >= 4 && gBitPlanes >= 4 && bBitPlanes >= 4)
  1721.     {
  1722.         if (showConfig)
  1723.         {
  1724.         printf("RGB double buffer mode is allowed.\n");
  1725.         }
  1726.  
  1727.         /*KLUDGE heuristic which assumes stuff about IRIS implementation*/
  1728.         if (rBitPlanes == gBitPlanes && gBitPlanes == bBitPlanes)
  1729.         {
  1730.         if (showConfig)
  1731.         {
  1732.             printf("RGB mode will work for user interface colors.\n");
  1733.         }
  1734.         rgbGoodForUI = true;
  1735.         }
  1736.         else
  1737.         {
  1738.         if (showConfig)
  1739.         {
  1740.             printf("RGB mode will NOT work for user interface colors.\n");
  1741.         }
  1742.         rgbGoodForUI = false;
  1743.         }
  1744.     }
  1745.     else
  1746.     {
  1747.         if (showConfig)
  1748.         {
  1749.         printf("There are not enough bit planes for double buffer RGB.\n");
  1750.         }
  1751.         hasRGBDouble = false;
  1752.     }
  1753.     }
  1754.     else
  1755.     {
  1756.     hasRGBDouble = false;
  1757.     if (showConfig)
  1758.     {
  1759.         printf("RGB double buffer vetoed\n");
  1760.     }
  1761.     }
  1762.  
  1763.     /*If not enough bit planes, shoot for single buffer*/
  1764.     if (!hasRGBDouble)
  1765.     {
  1766.     /*Try single buffer RGB*/
  1767.  
  1768.     /*See all bit planes for IBM version*/
  1769. #ifdef GD_BITS_NORM_DBL_RGB
  1770.     rBitPlanes = getgdesc(GD_BITS_NORM_SNG_RGB);
  1771.     gBitPlanes = getgdesc(GD_BITS_NORM_SNG_RGB);
  1772.     bBitPlanes = getgdesc(GD_BITS_NORM_SNG_RGB);
  1773. #endif
  1774.  
  1775.     /*Now individual bit planes for IRIS version*/
  1776. #ifdef GD_BITS_NORM_SNG_RED
  1777.     rBitPlanes = getgdesc(GD_BITS_NORM_SNG_RED);
  1778. #endif
  1779. #ifdef GD_BITS_NORM_SNG_GREEN
  1780.     gBitPlanes = getgdesc(GD_BITS_NORM_SNG_GREEN);
  1781. #endif
  1782. #ifdef GD_BITS_NORM_SNG_BLUE
  1783.     bBitPlanes = getgdesc(GD_BITS_NORM_SNG_BLUE);
  1784. #endif
  1785.  
  1786.     /*If not enough bit planes, shoot for single buffer*/
  1787.     if (rBitPlanes && gBitPlanes && bBitPlanes)
  1788.     {
  1789.         if (showConfig)
  1790.         {
  1791.         printf("RGB single buffer mode is allowed.\n");
  1792.         }
  1793.  
  1794.         /*KLUDGE heuristic which assumes stuff about IRIS implementation*/
  1795.         if (rBitPlanes == gBitPlanes && gBitPlanes == bBitPlanes)
  1796.         {
  1797.         if (showConfig)
  1798.         {
  1799.             printf("RGB mode will work for user interface colors.\n");
  1800.         }
  1801.         rgbGoodForUI = true;
  1802.         }
  1803.         else
  1804.         {
  1805.         if (showConfig)
  1806.         {
  1807.             printf("RGB mode will NOT work for user interface colors.\n");
  1808.         }
  1809.         rgbGoodForUI = false;
  1810.         }
  1811.     }
  1812.     else
  1813.     {
  1814.         if (showConfig)
  1815.         {
  1816.         printf("There are not enough bit planes for single buffer RGB.\n");
  1817.         }
  1818.         hasRGB = false;
  1819.     }
  1820.     }
  1821.     }
  1822.     else
  1823.     {
  1824.     hasRGB = false;
  1825.     }
  1826.  
  1827.     if (getenv("SCIAN_VETO_RGB_GOOD_FOR_UI"))
  1828.     {
  1829.     if (showConfig)
  1830.     {
  1831.         printf("RGB for user interface vetoed\n");
  1832.     }
  1833.     rgbGoodForUI = false;
  1834.     }
  1835.     else if (getenv("SCIAN_FORCE_RGB_GOOD_FOR_UI"))
  1836.     {
  1837.     if (showConfig)
  1838.     {
  1839.         printf("RGB for user interface forced\n");
  1840.     }
  1841.     rgbGoodForUI = true;
  1842.     }
  1843.  
  1844.     /*See if depth cueing is appropriate*/
  1845.     if (rBitPlanes < 3 || gBitPlanes < 3 || bBitPlanes < 3)
  1846.     {
  1847.     if (showConfig)
  1848.     {
  1849.         printf("Depth cueing is not practical with this number of bitplanes.\n");
  1850.     }
  1851.     hasDepthCue = false;
  1852.     }
  1853.     else
  1854.     {
  1855.     if (showConfig)
  1856.     {
  1857.         printf("There is depth cueing.\n");
  1858.     }
  1859.     hasDepthCue = true;
  1860.     }
  1861.  
  1862.     /*Now check double buffer color map mode*/
  1863.     if (tryCmap)
  1864.     {
  1865.     hasCmap = true;
  1866.     if (tryDouble)
  1867.     {
  1868.         hasCmapDouble = true;
  1869.         cmapBitPlanes = getgdesc(GD_BITS_NORM_DBL_CMODE);
  1870.  
  1871.         if (showConfig)
  1872.         {
  1873.         printf("%d double buffer color map bitplanes.\n", cmapBitPlanes);
  1874.         }
  1875.  
  1876.         if (cmapBitPlanes < MINCMAPBITPLANES)
  1877.         {
  1878.         /*Not enough bit planes for cmap*/
  1879.         if (showConfig)
  1880.         {
  1881.             printf("Not enough bit planes for double buffer color map mode (%d).\n", cmapBitPlanes);
  1882.         }
  1883.         hasCmapDouble = false;
  1884.         }
  1885.     }
  1886.  
  1887.     if (!hasCmapDouble)
  1888.     {
  1889.         /*Try single buffer*/
  1890.  
  1891.         cmapBitPlanes = getgdesc(GD_BITS_NORM_SNG_CMODE);
  1892.         if (showConfig)
  1893.         {
  1894.         printf("%d single buffer color map bitplanes.\n", cmapBitPlanes);
  1895.         }
  1896.         if (cmapBitPlanes < MINCMAPBITPLANES)
  1897.         {
  1898.         if (showConfig)
  1899.         {
  1900.             printf("Not enough bit planes for single buffer color map mode (%d).\n", cmapBitPlanes);
  1901.         }
  1902.         hasCmap = false;
  1903.         }
  1904.     }
  1905.     }
  1906.  
  1907.     if ((!hasCmap) && (!hasRGB))
  1908.     {
  1909.     printf("This computer does not have enough color bit planes to run SciAn.  SciAn\n");
  1910.     printf("requires at least nine color map bit planes or some RGB bit planes in\n");
  1911.     printf("order to work properly.\n");
  1912.     exit(-1);
  1913.     }
  1914.  
  1915.     /*Use RGB mode for user interface anyway*/
  1916.     rgbGoodForUI = true;
  1917.  
  1918. #ifdef GD_DITHER
  1919.     if (getgdesc(GD_DITHER))
  1920.     {
  1921.     if (showConfig)
  1922.     {
  1923.         printf("There is dithering.\n");
  1924.     }
  1925.     hasDithering = true;
  1926.     }
  1927.     else
  1928.     {
  1929.     if (showConfig)
  1930.     {
  1931.         printf("There is no dithering.\n");
  1932.     }
  1933.     hasDithering = false;
  1934.     }
  1935. #else
  1936.     if (showConfig)
  1937.     {
  1938.     printf("There is no dithering.\n");
  1939.     hasDithering = false;
  1940.     }
  1941. #endif
  1942.  
  1943.     scavengeColors = false;
  1944.  
  1945.     if (hasCmap && getenv("SCIAN_SCAVENGE_COLORS"))
  1946.     {
  1947.     scavengeColors = true;
  1948.     }
  1949.  
  1950. #ifdef GD_BLEND
  1951.     if (getgdesc(GD_BLEND))
  1952.     {
  1953.     hasTransparency = true;
  1954.     if (showConfig)
  1955.     {
  1956.         printf("There is blending transparency.\n");
  1957.     }
  1958.     }
  1959.     else
  1960. #endif
  1961.     {
  1962.     hasTransparency = false;
  1963.     if (showConfig)
  1964.     {
  1965.         printf("There is no blending transparency.\n");
  1966.     }
  1967.     }
  1968.  
  1969. #ifdef GD_LINESMOOTH_RGB
  1970.     if (getgdesc(GD_LINESMOOTH_RGB))
  1971.     {
  1972.     hasAntialiasedLines = true;
  1973.     if (showConfig)
  1974.     {
  1975.         printf("There is line anti-aliasing.\n");
  1976.     }
  1977.     }
  1978.     else
  1979. #endif
  1980.     {
  1981.     hasAntialiasedLines = false;
  1982.     if (showConfig)
  1983.     {
  1984.         printf("There is no line anti-aliasing.\n");
  1985.     }
  1986.     }
  1987.  
  1988. #ifdef GD_PNTSMOOTH_RGB
  1989.     if (getgdesc(GD_PNTSMOOTH_RGB))
  1990.     {
  1991.     hasAntialiasedPoints = true;
  1992.     if (showConfig)
  1993.     {
  1994.         printf("There is point anti-aliasing.\n");
  1995.     }
  1996.     }
  1997.     else
  1998. #endif
  1999.     {
  2000.     hasAntialiasedPoints = false;
  2001.     if (showConfig)
  2002.     {
  2003.         printf("There is no point anti-aliasing.\n");
  2004.     }
  2005.     }
  2006.  
  2007. #ifdef GD_LIGHTING_TWOSIDE
  2008.     if (getgdesc(GD_LIGHTING_TWOSIDE))
  2009.     {
  2010.     hasTwoSided = true;
  2011.     if (showConfig)
  2012.     {
  2013.         printf("There is hardware two-sided lighting available.\n");
  2014.     }
  2015.     }
  2016.     else
  2017. #endif
  2018.     {
  2019.     hasTwoSided = false;
  2020.     if (showConfig)
  2021.     {
  2022.         printf("There is no hardware two-sided lighting.\n");
  2023.     }
  2024.     }
  2025.  
  2026. #ifdef GD_BITS_ZBUFFER
  2027.     if (getgdesc(GD_BITS_ZBUFFER) > 0)
  2028. #else
  2029. #ifdef GD_BITS_NORM_ZBUFFER
  2030.     if (getgdesc(GD_BITS_NORM_ZBUFFER) > 0)
  2031. #else
  2032. !! No Z-buffer constant defined
  2033. #endif
  2034. #endif
  2035.     {
  2036.     hasZbuf = true;
  2037.     if (showConfig)
  2038.     {
  2039.         printf("There is a Z-buffer.\n");
  2040.     }
  2041.     }
  2042.     else
  2043.     {
  2044.     hasZbuf = false;
  2045.     if (showConfig)
  2046.     {
  2047.         printf("There is no Z-buffer.\n");
  2048.     }
  2049.     }
  2050.  
  2051.     if (getenv("SCIAN_VETO_ZBUFFER"))
  2052.     {
  2053.     if (showConfig)
  2054.     {
  2055.         printf("Z-buffer vetoed.\n");
  2056.     }
  2057.     hasZbuf = false;
  2058.     }
  2059.  
  2060.     if (getenv("SCIAN_FORCE_ZBUFFER"))
  2061.     {
  2062.     if (showConfig)
  2063.     {
  2064.         printf("Z-buffer forced.\n");
  2065.     }
  2066.     hasZbuf = true;
  2067.     }
  2068.  
  2069.     nOverDrawPlanes = 0;
  2070.     pupForOverDraw = false;
  2071.  
  2072. #ifdef GD_BITS_OVER_SNG_CMODE
  2073.     if (nOverDrawPlanes = getgdesc(GD_BITS_OVER_SNG_CMODE))
  2074.     {
  2075.     pupForOverDraw = false;
  2076.     if (showConfig)
  2077.     {
  2078.         printf("There are %d overlay planes.\n", nOverDrawPlanes);
  2079.     }
  2080.     }
  2081. #endif
  2082. #ifdef GD_BITS_PUP_SNG_CMODE
  2083.     if (!nOverDrawPlanes && (nOverDrawPlanes = getgdesc(GD_BITS_PUP_SNG_CMODE)))
  2084.     {
  2085.     pupForOverDraw = true;
  2086.     if (showConfig)
  2087.     {
  2088.         printf("There are %d popup planes.\n", nOverDrawPlanes);
  2089.     }
  2090.     }
  2091. #endif
  2092.  
  2093. #ifdef GD_BITS_OVERLAY
  2094.     if (!nOverDrawPlanes && ((nOverDrawPlanes = getgdesc(GD_BITS_OVERLAY)) > 0))
  2095.     {
  2096.     pupForOverDraw = false;
  2097.     if (showConfig)
  2098.     {
  2099.         printf("There are %d overlay planes.\n", nOverDrawPlanes);
  2100.     }
  2101.     }
  2102. #endif
  2103.  
  2104.     if ((!nOverDrawPlanes) && showConfig)
  2105.     {
  2106.     printf("There are no overlay planes.\n");
  2107.     }
  2108.  
  2109.     if (getenv("SCIAN_VETO_OVERLAY"))
  2110.     {
  2111.     if (showConfig)
  2112.     {
  2113.         printf("Overlay planes vetoed.\n");
  2114.     }
  2115.     nOverDrawPlanes = 0;
  2116.     }
  2117.  
  2118.     if (getenv("SCIAN_FORCE_OVERLAY"))
  2119.     {
  2120.     if (showConfig)
  2121.     {
  2122.         printf("Overlay planes forced.\n");
  2123.     }
  2124.     nOverDrawPlanes = 2;
  2125.     }
  2126.  
  2127.     if (getenv("SCIAN_FORCE_STEREO"))
  2128.     {
  2129.     if (showConfig)
  2130.     {
  2131.         printf("Stereo forced.\n");
  2132.     }
  2133.     hasStereo = true;
  2134.     }
  2135.     else
  2136.     {
  2137. #ifdef GD_STEREO
  2138.     hasStereo = getgdesc(GD_STEREO) ? true : false;
  2139. #else
  2140.     hasStereo = false;
  2141. #endif
  2142.     if (showConfig)
  2143.     {
  2144.         printf(hasStereo ? "Stereo mode is available.\n" :
  2145.             "Stereo mode is not available.\n");
  2146.     }
  2147.     }
  2148.  
  2149. #endif
  2150. }
  2151.  
  2152. ObjPtr SetWindowToRGB(window)
  2153. WinInfoPtr window;
  2154. /*Method to set a window to RGB mode*/
  2155. {
  2156.             if (window -> flags & WINRGB)
  2157.             {
  2158.             /*Do nothing*/
  2159.             }
  2160.             else
  2161.             {
  2162.             window -> flags |= WINRGB;
  2163.             SelWindow(window);
  2164.             SetMode(window);
  2165.             ImInvalid((ObjPtr) window);
  2166.             }
  2167.     return ObjTrue;
  2168. }
  2169.  
  2170. ObjPtr SetWindowToCmap(window)
  2171. WinInfoPtr window;
  2172. /*Method to set a window to Cmap mode*/
  2173. {
  2174.             if (window -> flags & WINRGB)
  2175.             {
  2176.             window -> flags &= ~WINRGB;
  2177.             SelWindow(window);
  2178.             SetMode(window);
  2179.             ImInvalid((ObjPtr) window);
  2180.             }
  2181.             else
  2182.             {
  2183.             /*Do nothing*/
  2184.             }
  2185.     return ObjTrue;
  2186. }
  2187.  
  2188. void InitWindows()
  2189. /*Initializes the window system*/
  2190. {
  2191.     long dim;
  2192.  
  2193.     windowClass = NewObject(NULLOBJ, 0);
  2194.     SetMethod(windowClass, DISPOSE, DisposeWindow);
  2195.     SetVar(windowClass, TYPESTRING, NewString("window"));
  2196.     SetMethod(windowClass, SETTORGBMODE, SetWindowToRGB);
  2197.     SetMethod(windowClass, SETTOCMAPMODE, SetWindowToCmap);
  2198.     SetMethod(windowClass, OPENMANUALLY, OpenWindowManually);
  2199.     AddToReferenceList(windowClass);
  2200.  
  2201.     /*Create the clipboard*/
  2202.     dim = 1;
  2203.     clipboard = NewArray(AT_OBJECT, 1, &dim);
  2204.     AddToReferenceList(clipboard);
  2205. }
  2206.  
  2207. void KillWindows()
  2208. /*Kills the window system*/
  2209. {
  2210.     DeleteThing(clipboard);
  2211.     DeleteThing(windowClass);
  2212. }
  2213.  
  2214.